﻿@using MvcPaging
@model MvcApplication5.Models.SearchModel

@{
    ViewBag.Title = "Published";
    Layout = "~/Views/News/AdminLayout.cshtml";
}

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script>
    $(function () {
        $("#datepicker").datepicker({ dateFormat: "mm/dd/yy" });
    });

    $(function () {
        $("#datepicker2").datepicker({ dateFormat: "mm/dd/yy" });
    });
</script>



<h2>Bài đã xuất bản</h2>
@using(Html.BeginForm()){
    <table border="1">
        <tr class="news-header">
            <th><input type="checkbox" /></th>
            <th>Tiêu đề tin</th>
            <th style="width:100px;">Chuyên mục</th>
            <th>Lượt xem</th>        
        </tr>
        @foreach (var item in Model.newsList)
        {
            var Author = item.Author != null ? item.Author.Name : "";     
            <tr class="news-content">
                <td><input type="checkbox" id="chkBox" name="chkBox" value="@item.NewsId"/></td>
                <td style="width:832px; padding-left:5px;">
                    <a href="/News/Edit/@item.NewsId?UserType=TBT&FromPage=@ViewBag.Title" class="news-title">@item.Title</a>
                    @if (item.PublishedDate <= DateTime.Now){
                        <p class="news-subtitle">Tác giả: @Author, ngày XB: @item.PublishedDate, người XB: @item.PublishedBy, lần sửa cuối: @item.LastModifiedDate, người sửa: @item.LastModifiedBy</p>
                    }else{
                        <p class="news-subtitle">Tác giả: @Author, ngày XB: <span style="color:red; font-weight:bold;">@item.PublishedDate</span>, người XB: @item.PublishedBy, lần sửa cuối: @item.LastModifiedDate, người sửa: @item.LastModifiedBy</p>
                    }
                </td>
                <td class="news-text">@Html.DisplayFor(modelItem => item.Category.Name)</td>
                <td style="width:130px; text-align:center; font-size:12px;">@item.ViewCount</td>
            </tr>
        }
            @if(ViewBag.Type == "Search"){
                <tr>
                    <td colspan="4" style="border:none;">@Html.Pager(Model.newsList.PageSize, Model.newsList.PageNumber, Model.newsList.TotalItemCount).Options(o => o.AddRouteValue("Type", "Search"))</td>
                </tr>    
            }else{
                <tr>
                    <td colspan="4" style="border:none;">@Html.Pager(Model.newsList.PageSize, Model.newsList.PageNumber, Model.newsList.TotalItemCount)</td>
                </tr>    
            }               
    </table>
    <div class="news-command"><input type="submit" name="submitButton" value="gỡ tin đã chọn"/></div>
    <div class="news-search">
        <table>
            <tr>
                <td class="news-search-left">Từ khóa</td>
                <td class="news-search-keyword">@Html.TextBoxFor(model => model.searchObject.Title, new { style = "width:500px;"})</td>
                <td><input type="submit" name="submitButton" value="Tìm kiếm"/></td>
            </tr>
            <tr>
                <td class="news-search-left">Chuyên mục</td>
                <td colspan="2">
                    @Html.DropDownListFor(m => m.searchObject.CategoryId, new SelectList(Model.categoryList, "CategoryId", "Name"),"--- Tất cả ---")                    
                </td>                
            </tr>
            <tr>
                <td class="news-search-left">Tác giả</td>
                <td colspan="2">
                    @Html.DropDownListFor(m => m.searchObject.AuthorId, new SelectList(Model.authorList, "AuthorId", "Name"),"--- Tất cả ---")
                </td>                
            </tr>                                 
            <tr>
                <td class="news-search-left">Ngày xuất bản</td>
                <td colspan="2">Từ ngày: <input type="text" id="datepicker" name="datepicker"/> Đến ngày: <input type="text" id="datepicker2" name="datepicker2"/></td>                
            </tr>
        </table>
    </div>
}

    
